# Hook {{{1 #
set -g @plugin imomaliev/tmux-peacock
# 1}}} Hook #

# Default {{{1 #
set -g prefix C-q
set -g mouse on
set -g history-file ~/.cache/tmux.conf
set -g extended-keys always
set -g set-clipboard on
set -g word-separators ' -_@'
set -g status-position top
set -g renumber-windows on
set -g set-titles on
set -g set-titles-string "#S:#I #W#{session_alerts}"
set -g monitor-activity on
set -g pane-base-index 1
set -g status-interval 60
set -g base-index 1
bind 0 select-window -t :=10

set -g @plugin tmux-plugins/tmux-sensible
set -g @plugin lljbash/tmux-update-display
# 1}}} Default #

# PluginManage {{{1 #
if '[[ ! -d ~/.config/tmux/plugins/tpm ]] && (($+commands[git]))' {
  run 'git clone --depth=1 https://github.com/tmux-plugins/tpm \
~/.config/tmux/plugins/tpm && ~/.config/tmux/plugins/tpm/bin/install_plugins'
}
set -g @plugin tmux-plugins/tpm
# 1}}} PluginManage #

# StatusLine {{{1 #
# install wqy-zenhei
set -g @plugin Freed-Wu/tmux-status-bar
set -g @plugin Freed-Wu/tmux-digit
set -g @plugin Freed-Wu/tmux-bitahub
set -g @plugin tmux-plugins/tmux-prefix-highlight
set -g @plugin olimorris/tmux-pomodoro-plus
set -g @pomodoro_on "#[fg=$text_red]🍅"
set -g @pomodoro_complete "#[fg=$text_green]🍅"
set -g @pomodoro_toggle a
set -g @pomodoro_cancel A
set -g @plugin tmux-plugins/tmux-online-status
set -g @route_to_ping github.com
set -g @plugin tmux-plugins/tmux-net-speed
set -g @net_speed_format '↓%8s↑%8s'
set -g @plugin tmux-plugins/tmux-cpu
set -g @plugin tmux-plugins/tmux-battery
set -g @plugin Brutuski/tmux-ticker
set -g @ticker_crypto BTC-USD
set -g @plugin aaronpowell/tmux-weather
set -g status-left-length 1000
set -g status-right-length 1000
set -g window-status-separator ''
set -g window-status-format \
"#[noreverse] #I #W\
#{?window_marked_flag,,}\
#{?window_zoomed_flag,󰍉,}\
#{?window_linked,,}\
#{?window_last_flag,󰍎,}\
#{?window_bell_flag,󰂟,}\
#{?window_silence_flag,,} "
set -g window-status-current-format \
"#{window-status-current-format-left:black,#ffb86c,#[bold]#I #W\
#{?window_marked_flag,,}\
#{?window_zoomed_flag,󰍉,}\
#{?window_linked,,}\
#{?window_bigger,,}}"
set -g status-left "#{status-left:#fffafa,black,#S}"
# if battery_percentage is 0%, this is a desktop, don't show battery status
# if not, this is a laptop, its screen size is small, don't show many long items
set -g status-right \
"#{status-right:%s;\
white,colour04,#{prefix_highlight}#[bg=colour04];\
black,yellow,#{pomodoro_status};\
\
black,#9370db,\
#{?#{==:#{bitahub_status_gtx1080ti},},,1080ti #{bitahub_status_gtx1080ti}}\
#{?#{||:#{==:#{bitahub_status_rtx3090},},#{==:#{bitahub_status_gtx1080ti},}},,}\
#{?#{==:#{bitahub_status_rtx3090},},,3090 #{bitahub_status_rtx3090}};\
\
white,#b34a47,\
#{?#{||:#{==:#{battery_percentage},0%},#{==:#{battery_percentage},}},\
#{net_speed},#{battery_icon_status}#{battery_remain}\
#{battery_color_status_fg}#[bg=#b34a47]\
#{battery_icon_charge}#{battery_percentage}};\
\
black,#87ceeb,%F%H:%M%a}"
# average load is too large
#{cpu_fg_color}#{cpu_icon}#{cpu_percentage} \
#{ram_fg_color}#{ram_icon}#{ram_percentage} \
#{cpu_temp_fg_color}#{cpu_temp_icon}#{cpu_temp}\
#{gpu_fg_color}#{gpu_icon}#{gpu_percentage} \
#{gram_fg_color}#{gram_icon}#{gram_percentage} \
#{gpu_temp_fg_color}#{gpu_temp_icon}#{gpu_temp}\
#{ticker_crypto}\
#{forecast}\
# 1}}} StatusLine #

# Hotkey {{{1 #
set -g @plugin tmux-plugins/tmux-pain-control
set -g @plugin tmux-plugins/tmux-sessionist
set -g @plugin tmux-plugins/tmux-logging
set -g @plugin tmux-plugins/tmux-yank
set -g @yank_action copy-pipe
set -g @copy_mode_put c
set -g @copy_mode_yank_put M-c
set -g @plugin tmux-plugins/tmux-resurrect
set -g @resurrect-strategy-vim session
set -g @resurrect-strategy-nvim session
set -g @resurrect-capture-pane-contents on
set -g @plugin IngoMeyer441/tmux-easy-motion

bind -Tcopy-mode-vi r clear-history
bind -Tcopy-mode-vi = capture-pane
bind -Tcopy-mode-vi v send-keys -X begin-selection
bind -Tcopy-mode-vi M-v send-keys -X rectangle-toggle
bind -Tcopy-mode-vi C-v send-keys v M-v
bind -Tcopy-mode-vi u send-keys -X halfpage-up
bind -Tcopy-mode-vi d send-keys -X halfpage-down
bind -Tcopy-mode-vi U send-keys -X page-up
bind -Tcopy-mode-vi D send-keys -X page-down
bind -Tcopy-mode-vi i send-keys -X append-selection-and-cancel
bind -Tcopy-mode-vi I send-keys -X append-selection-and-cancel
bind -Tcopy-mode-vi a send-keys -X append-selection-and-cancel
bind -Tcopy-mode-vi Y send-keys 'v$hy'
bind -Tcopy-mode-vi C send-keys 'v$hc'
bind -Tcopy-mode-vi M-C send-keys 'v$h' M-c
bind ` last-window
bind T clock
bind C-c new-session
bind C-f command-prompt -p find-session 'switch-client -t %%'
# 1}}} Hotkey #

# Tool {{{1 #
# File {{{2 #
# load early because it need more time
set -g @plugin tmux-plugins/tmux-sidebar
set -g @sidebar-tree C-t
set -g @sidebar-tree-focus t
set -g @sidebar-tree-command 'exa -T --icons --color=always'
# 2}}} File #

# Filter {{{2 #
set -g @plugin laktak/extrakto
set -g @plugin kevinhwang91/fzf-tmux-script
if '[[ -d ~/.config/tmux/plugins/fzf-tmux-script ]]' {
  set-hook -g pane-focus-in[10] {
    run -b '~/.config/tmux/plugins/fzf-tmux-script/panes/fzf-panes.tmux \
update_mru_pane_ids'
  }
  bind w run -b '~/.config/tmux/plugins/fzf-tmux-script/panes/fzf-panes.tmux \
new_window'
}
# 2}}} Filter #

# Query {{{2 #
set -g @plugin knakayama/tmux-man
set -g @man-key O
# MANPAGER need it
set -g @man-shell-interactive on
# 2}}} Query #

# Browse {{{2 #
set -g @plugin tmux-plugins/tmux-open
set -g @open x
set -g @open-X https://www.google.com/search?q=
# 2}}} Browse #
# 1}}} Tool #

# SessionManage {{{1 #
set -g @plugin tmux-plugins/tmux-continuum
# 1}}} SessionManage #

run ~/.config/tmux/plugins/tpm/tpm
# ex: foldmethod=marker
